package com.azier.kapacitor.script.node;

import com.azier.kapacitor.script.method.*;
import com.azier.kapacitor.script.node.nodebind.CommonNodeBind;

import java.util.ArrayList;

/**
* 1 * @Author: luoj
* 2 * @Date: 2019/11/8 11:27
* 3
*/

/**
 Create a new node that windows the stream by time.
**/

/**
创建一个新的window节点，该节点定期发出BarrierMessage
**/
public class WindowNode extends AbstractNode implements CommonNodeBind{
    private static final String name = "window";

    public WindowNode() {
        super(new ArrayList<>(),new ArrayList<>(),name);
    }

    public WindowNode align(){
        Align align = new Align();
        super.addMethod(align);
        return this;
    }

    public WindowNode every(long interval, String durationLiteral){
        Every every = new Every(interval,durationLiteral);
        super.addMethod(every);
        return this;
    }

    public WindowNode everyCount(long value){
        EveryCount everyCount = new EveryCount(value);
        super.addMethod(everyCount);
        return this;
    }

    public WindowNode fillPeriod(){
        FillPeriod fillPeriod = new FillPeriod();
        super.addMethod(fillPeriod);
        return this;
    }

    public WindowNode period(long interval, String durationLiteral){
        Period period = new Period(interval, durationLiteral);
        super.addMethod(period);
        return this;
    }
    public WindowNode periodCount(long value){
        PeriodCount periodCount = new PeriodCount(value);
        super.addMethod(periodCount);
        return this;
    }

    public WindowNode quiet(){
        Quiet quiet = new Quiet();
        super.addMethod(quiet);
        return this;
    }
}